home *** CD-ROM | disk | FTP | other *** search
NeXT TypedStream Data | 1994-12-14 | 32.5 KB | 636 lines |
- typedstream
- IBObjectData
- Object
- CustomObject
- Responder
- Title
- Helvetica
- ScrollView
- ClipView
- ciifffcfffs
- [175c]{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
- \margl40
- \margr40
- \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs24\fc0\cf0 new=old
- NXCursor
- NXImage
- NXibeam
- Scroller
- Control
- _doScroller:
- @@@ffs
- TextField
- TextFieldCell
- ActionCell
- Popi code
- Matrix
- @:@iiii
- ButtonCell
- NXCachedImageRep
- NXImageRep
- iisssss
- iiiiii
- ff@@#::s
- Radio
- NXradio
- NXradioH
- Color Channels
- Button
- Presets
- MenuTemplate
- *@*@ccc
- OtherViews
- [13@]
- MenuCell
- Variables
- Unsharp
- Relief
- Shrink
- Circular
- Transform
- Swirl
- Swirl2
- Radial Blend
- Radar Sweep
- Spiral
- B/W Pattern
- PopUpList
- popUp:
- NXpulldown
- NXpulldownH
- Limiter
- NXswitch
- NXswitchH
- Parameters
- FormCell
- Field:
- Slider
- SliderCell
- dddf@d@d
- WindowTemplate
- iiii***@s@
- This window never appears
- Window
- VThis module implements the popi language for image manipulation by Gerald J. Holzmann.
- Helvetica-Oblique
- VERSION 1.0
- $COPYRIGHT 1992, UNTER ECKER SOFTWARE^
- *adapted and extended by Oliver Unter Ecker
- CICicon
- CIC Popi
- Module Help
- Panel
- [27077c]{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
- \margl40
- \margr40
- {\colortbl;\red0\green0\blue0;}
- \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i0\ulnone\fs24\fc1\cf1 POPI(1L) UNIX Programmer's Manual POPI(1L)\
- NAME\
- popi - perform interactive digital image transformations\
- SYNOPSIS\
- popi [option] ... [file] ...\
- DESCRIPTION\
- Popi is a program which allows arbitrary transformations to\
- be interactively applied to digital images. It is based on\
- the program described in "Beyond Photography - The Digital\
- Darkroom" by Gerald J. Holzmann.\
- The meanings of the available command line options are as\
- follows:\
- -V Print program version identification message and exit.\
- -xWidth\
- Set the image width (number of pixels per scanline) to\
- Width .\
- -yHeight\
- Set the image height (number of scanlines) to Height .\
- -v+ Set the verbose flag on. Be chatty about a number of\
- things.\
- -v- Turn the verbose flag off. Be silent about everything\
- except error messages.\
- -a+ Turn auto-display on. After each image transformation,\
- the image will be displayed. Equivalent to the\
- #display + command.\
- -a- Turn auto-display off. Equivalent to the #display -\
- command. Images can still be displayed explicitly with\
- the #display image command.\
- -p[ncpus]\
- On a Sequent multiprocessor, use the specified number\
- of cpus to perform the transform. If this option is\
- given without a number, the maximum number available is\
- used. This option has no effect on uniprocessor com-\
- puters.\
- -l[logfile]\
- Enables logging of all input, error messages, and some\
- responses. Logging is done on the named file, or the\
- file "popi.log" if no name is given. The #logfile com-\
- mand may also be used to turn logging on and off.\
- An image transform is described by a transform statement.\
- The statement basically takes the form\
- dest = expression\
- where dest indicates the new image and expression describes\
- a transformation. This statement is executed over the range\
- of image coordinates. For a 512 x 512 image, it will be\
- executed 262144 times. An image is normally referenced in a\
- statement by its name and an index. A cartesian index is\
- specified by using the x and y coordinates in square brack-\
- ets after the image name. Thus dmr[0,0] is the top left\
- pixel in the image named dmr. Polar coordinates may be\
- specified by giving a radius and angle (in degrees) in curly\
- brackets. Thus dmr\{0,0\} refers to the centre pixel in the\
- image. The symbols x and y may appear in the transform\
- statement. These take on values corresponding to a dif-\
- ferent pixel each time the transform is executed. Inter-\
- nally the algorithm is as follows\
- for y varying from 0 to Y\
- for x varying from 0 to X\
- execute transform statement\
- where Y is the maximum y coordinate and X is the maximum x\
- coordinate. The image size can be set on the command line\
- as described later.\
- The value of a pixel varies from 0 to 255 in the current\
- implementation. Any value outside this range is treated as\
- modulo 256 when being stored in an image (ie. it wraps\
- around). Low numeric values represent dark colours, while\
- large values represent light colours. A simple transform\
- statement to set an image to completely black would be\
- new[x,y] = 0 ; set image to black\
- The name new is one of the two default images always main-\
- tained internally. The other is old. The images referred to\
- by these names are swapped after each operation, so a suc-\
- cession of transforms may modify the "old" image to produce\
- a "new" image. Thus the statement\
- new[x,y] = old[x,y] / 2 ; darken image\
- will reduce all the pixel intensity values by a half, dark-\
- ening the existing image. The semicolon (`;') character\
- introduces a comment. Anything from this to the end of the\
- line is ignored.\
- All the standard arithmetic, relational and boolean opera-\
- tors from the C language are available, with precedence gen-\
- erally as per the C language. Some additional operators,\
- predefined variables and math functions are also available.\
- Here is a listing of the available symbols and their mean-\
- ings.\
- name Refers to an image name. If not followed by index\
- brackets, the index [x,y] is assumed. The currently\
- available names are those shown by the #list display,\
- and also old and new.\
- $n Where n is a digit, this is an alternative method of\
- referring to an image. In fact this may be the only\
- method if the image name contains punctuation charac-\
- ters. The #list command shows the correspondence\
- between image names and this form of reference.\
- X The maximum x coordinate value. This is one less than\
- the number of pixels per scanline (image width), which\
- may be set with the -x command line option.\
- Y The maximum y coordinate value. This is one less than\
- the number of scanlines (the height of the image),\
- which may be set with the -y command line option.\
- x The current cartesian x coordinate. Varies from 0\
- (left of image) to X (right of image).\
- y The current cartesian y coordinate. Varies from 0 (top\
- of image) to Y (bottom of image).\
- r The radius component of the polar coordinate which\
- corresponds to the current cartesian (x,y) coordinate.\
- This is equivalent to sqrt(x*x + y*y) with a transla-\
- tion of the origin.\
- a The angle component of the polar coordinate which\
- corresponds to the current cartesian (x,y) coordinate.\
- This is equivalent to (and a shorthand for) atan(y/x).\
- Note that the first time in a popi session you use an\
- expression with either r or a in it, you may notice an\
- extra delay before the image transformation begins.\
- This is due to precalculation of an array of polar\
- coordinates that happens the first time you use one.\
- R The maximum radius value of a polar coordinate.\
- A The maximum angle value of a polar coordinate (this is\
- just 360).\
- Z The maximum intensity value of a pixel (corresponding\
- to white). Currently, this is always 255.\
- ** The exponentiation (raise to the power) operator. The\
- expression x ** 2 means x squared (x * x).\
- * The multiplication operator. This has a higher pre-\
- cedence than division to avoid underflow in expressions\
- with multiplication and division, since normally\
- expressions are evaluated as integers.\
- / Integer division. If the divisor is 0, the result is\
- set to Z.\
- % Modulo. If the divisor (right hand operand) is 0, the\
- result is set to 0.\
- + Addition.\
- - Subtraction. This may be a unary or a binary operator.\
- << Left shift. The left operand is shifted left the\
- number of bits specified by the right operand.\
- >> Right shift. The left operand is shifted right the\
- number of bits specified by the right operand.\
- > Greater than. As with all the relational operators, if\
- the specified relation between the operands is true,\
- the result is 1, otherwise the result is 0.\
- < Less than.\
- >= Greater than or equal to.\
- <= Less than or equal to.\
- == Test for equality.\
- != Not equal to.\
- & Bitwise (arithmetic) AND operator.\
- ^ Bitwise exclusive OR (XOR) operator.\
- | Bitwise (arithmetic) OR operator.\
- && Logical AND operator. The result is 1 if both of the\
- operands are true (non-zero); otherwise the result is\
- 0. Unlike the && operator of the C language, this\
- operator is currently not conditional. Both operands\
- are always evaluated.\
- || Logical OR operator. The result is 1 if both either\
- (or both) of the operands are true (non-zero); other-\
- wise the result is 0. Unlike the || operator of the C\
- language, this operator is currently not conditional.\
- Both operands are always evaluated.\
- sin(expr)\
- This gives the value of the trigonometric sine of the\
- expression, multiplied by Z. This is required because\
- all operations are performed with integers.\
- cos(expr)\
- This gives the value of the trigonometric cosine of the\
- expression, multiplied by Z. This is required because\
- all operations are performed with integers.\
- atan(y-expr,x-expr)\
- This returns the trigonometric arctangent (inverse\
- tangent) of y-expr/x-expr in degrees (ie the value\
- returned will be between 0 and 360).\
- log(expr)\
- Returns the natural logarithm of the expression.\
- sqrt(expr)\
- Returns the square root of the expression.\
- rand()\
- Returns a positive random number. This will usually be\
- used with the modulo or bitwise AND operator to res-\
- trict the range of the result. For example,\
- new[x,y] = old[x,y] + rand() % 20 - 10\
- will adjust the brightness levels of each pixel in the\
- old image by a random amount (up to 10 levels brighter\
- or darker).\
- As well as allowing transformation statements, a number of\
- special commands, each starting with a # character, are\
- allowed. These are described here.\
- #read "filename" [image-name]\
- Read a raw data file into the named image. If no image\
- name is specified, the name is derived from the base\
- name component of the filename. If the name already\
- exists, that image is overwritten in memory, otherwise\
- a new image is created. If the filename does not\
- exist, but the same name with a ".Z" suffix does exist,\
- it is assumed that the file is compressed and the\
- "zcat" program is used to read the compressed image.\
- Note that when the image name defaults to the file\
- name, only the basename (portion after the last '/'\
- character, if any) is used to name the image. If this\
- resulting name starts with a digit, or contains any\
- characters other than alphabetic, digits and the under-\
- score, you will not be able to reference the image by\
- name, but will have to use the alternative "$n" syntax.\
- #write "filename" [image-name]\
- Write a raw data file from the named image. The image\
- name is optional, and if not specified, image "old" is\
- used. If the first character of the filename is `|',\
- the rest of the filename is interpreted as a command to\
- be run, with the raw image data being fed to it as\
- standard input.\
- #list\
- All the named images (other than "old" and "new" are\
- listed).\
- #genps "filename" [image-name]\
- Generate postscript to produce the image. The image\
- name is optional, and if not specified, image "old" is\
- used. The image will be scaled to fit whatever paper\
- size is being used. As with the #write command, if the\
- first character of the filename is a `|' symbol, the\
- rest of the string will be treated as a command to be\
- executed, with the postscript being piped to its stan-\
- dard input. This is convenient for printing images on\
- a PostScript printer.\
- #undo\
- The old and new images are swapped. This has the\
- effect of restoring the image that existed before the\
- last transformation.\
- #genepson "filename" [image-name]\
- Generate data for an Epson (or compatible) printer to\
- produce the image. The image name is optional, and if\
- not specified, image "old" is used. Under MSDOS, the\
- device name can be used directly (eg "PRN").\
- The existing code is for a 24-pin printer such as the\
- LQ-500. To generate data for an 8-pin printer requires\
- a couple of minor modifications to function genepson()\
- in file special.c.\
- #undo\
- The old and new images are swapped. This has the\
- effect of restoring the image that existed before the\
- last transformation.\
- #display image-name\
- The named image will be displayed. This is the fastest\
- way to display an image, and works regardless of the\
- state of auto-display.\
- #display +\
- Turn auto-display on (equivalent to the command-line\
- option -a+ ).\
- #display -\
- Turn auto-display off (equivalent to the command-line\
- option -a- ).\
- #truncate +\
- All assignments to an image with values outside the\
- range 0 to Z will be truncated to the appropriate boun-\
- dary, instead of wrapping as described in the book. An\
- example of using this feature would be for a simplistic\
- lightening of an image by adding a constant value.\
- Normally, very white areas would wrap around and become\
- black, but enabling truncation prevents this.\
- #truncate -\
- All assignments to an image will be done modulo (Z+1).\
- This is the default.\
- #verbose +\
- Turn on verbose mode. Equivalent to the -v+command\
- Certain warning messages will be printed. This turns\
- on the "percent done" feature of some drivers (on oth-\
- ers it is always active).\
- #truncate\
- Report whether truncation is currently in effect or\
- not.\
- #verbose -\
- Turn off verbose mode. Equivalent to the -v-command\
- #verbose\
- Report the state of the verbose flag.\
- #logfile +\
- Enable logging on the current log file (default\
- "popi.log"). If logging is already enabled, the file\
- is closed and re-opened with a new timestamp appended.\
- #logfile -\
- Disable logging"\
- #logfile "filename"\
- Enable logging on the specified file.\
- Whenever a log file is opened, it is always opened in\
- append mode, so existing data is never truncated. Upon\
- opening a log file, a timestamp is written. All user\
- input is logged, along with error messages and some\
- program responses.\
- #free imagename\
- The memory associated with the named image is freed.\
- Any further access to this image becomes impossible.\
- This command may be useful in situations where memory\
- is very limited, such as a PC.\
- The remaining special commands are used to obtain special\
- built-in transformations, as described in Chapter 6 of\
- "Beyond Photography". In each of these cases, the image\
- name is optional, and defaults to "old". In each case\
- (except for #melt), the result is stored in "new", and then\
- "old" and "new" are swapped as usual. In the case of #melt,\
- the transformation is done in place and no swap occurs.\
- #oil image-name\
- #shear image-name\
- #slice image-name\
- #tile image-name\
- #melt image-name\
- #matte image-name gamma\
- In this case, gamma is an optional floating point\
- number (defaults to 7.5). See the book for details.\
- DIFFERENCES\
- There are a number of differences between the Pico inter-\
- preter, for which the examples in the book are written, and\
- the Popi interpreter as implemented here.\
- Integer evaluation stack. The current version of the inter-\
- preter has an integer evaluation stack. For this reason,\
- the sin() and cos() functions, have their results multiplied\
- by Z automatically in order to be significant. A future\
- version of the interpreter will provide the option for a\
- floating point stack, and a syntax which will handle both\
- cases.\
- Polar coordinates. In the book, both cartesian and polar\
- coordinates are specified with square brackets. The deci-\
- sion of whether to interpret the indices as polar or carte-\
- sian is based on context; if the symbols r and a are used in\
- the index expressions, the coordinates are interpreted as\
- polar, otherwise they are interpreted as rectangular. Thus,\
- in order to use a radius or angle in a cartesian coordinate\
- expression, it must be cast, as is done on page 48 of the\
- book. By providing a separate syntax for polar and carte-\
- sian coordinate references, the problem never occurs.\
- EXAMPLES\
- These examples are mainly taken from the book, with syntax\
- modifications where required. The images in the book are\
- usually 1000 x 1000 pixels. To produce the same results on\
- a smaller image, you may need to multiply any occurences of\
- x, y and r by an appropriate scaling factor. The first\
- example image generation in the book is\
- new[x,y] = x + y ; page 17 (3.1)\
- which produces a number of diagonal stripes, each fading\
- from black to white. On a 512 x 512 image, to get the same\
- number of stripes, use the transform\
- new[x,y] = x*2 + y*2\
- A series of ripples can be produced with\
- new[x,y] = (x * y) % (Z + 1) ; page 18 (3.2)\
- or more simply, because all brightness values are inherently\
- modulo (Z + 1) unless truncation is turned on\
- new[x,y] = x * y\
- A single smooth transition can be accomplished with\
- new[x,y] = (Z * x * y) / ((X-1) * (Y-1)) ; page 18 (3.3)\
- The transformation\
- new[x,y] = x % y\
- is the same as new[x,y] = x when x < 0 (ie in the lower left\
- triangle of the image, with a different effect in the upper\
- right half.\
- The trig functions allow transforms such as\
- new[x,y] = y + sin(x) / 2 ; page 19 (3.5)\
- which produce a series of sine waves (remember that the\
- range of sin(x) is +-Z.\
- An image reminiscent of a radar sweep can be produced by\
- new[x,y] = atan(y - Y/2, x - X/2) * Z / 360 ; page 19 (3.6)\
- The atan() function has a range of 0 .. 360, so the *Z/360\
- rescales to 0 .. Z. This transform is overall providing an\
- intensity relative to the angle of a point in polar\
- coordinates. The transform language provides the current\
- angle as the variable a, so this statement can be rewritten\
- as\
- new[x,y] = a * Z / 360\
- Polar coordinates can be used to produce an image which\
- varies from black in the centre to white on the outside\
- new[x,y] = r * Z / R ; page 21 (3.11)\
- or a spiraling effect\
- new[x,y] = (((a + r) % 16) - 8) * Z / 16 + Z/2 ; page 21 (3.12)\
- The conditional operator can be used to provide a filled\
- black circle\
- new[x,y] = r > R/2 ? 0 : Z\
- or black and white patterns such as\
- new[x,y] = ((x % (5 + y/25)) > 5) ? 0 : Z ; page 20 (3.9)\
- new[x,y] = (Z * abs(x % sin(y)) > 10) ? 0 : Z ; page 20 (3.10)\
- We can also modify existing images using these transforms.\
- The previous image can always be referred to as old, or an\
- explicitly named image can be used. We can read an image\
- (eg of Dennis Ritchie) using\
- #read "dmr" ; read the image in the file "dmr" and name it dmr.\
- and then use it in a transform, such as\
- new[x,y] = Z - dmr[x,y] ; page 22 (3.13)\
- This produces a negative, which can be written to a file\
- with\
- #write "dmr_neg"\
- or converted to PostScript and printed with\
- #genps "| lp -dalw"\
- Since the new image built during a transformation becomes\
- the old image of the following transform, the negative image\
- can be re-reversed to produce the original with\
- new[x,y] = Z - old[x,y] ; reverse the process\
- In the following examples, we will use old in most of the\
- transforms, rather than a particular image name. In prac-\
- tice, you would probably use a specifically named image\
- instead.\
- Provide a circular frame for an image\
- new[x,y] = r > R/2 ? 0 : old[x,y]\
- A solarisation process, that fades in from left to right\
- new[x,y] = (old[x,y] > (Z*x) / (2 * X)) ? old[x,y] : Z-old[x,y] ; page 22 (3.16)\
- Generate a relief map\
- new[x,y] = old[x,y] + (Z/2 - old[x+2,y+2]) ; page 24 (3.19)\
- Shrink an image\
- new[x,y] = old[x*2,y*2] ; page 25 (3.24)\
- An interesting caricature is produced by\
- new[x,y] = old\{sqrt(r * R),a\} ; page 34\
- Note the use of polar coordinates. The reverse transform\
- gives a fisheye lens effect:\
- new[x,y] = old\{(r*r)/R, a\} ; page 60\
- The following transform illustrates how an expression can be\
- used for the indices of the destination matrix.\
- new[x, y-old[x,y]/4] = old[x,y] ; page 40\
- An image can be swirled about the centre with\
- new[x,y] = old\{r, a + r/3\}\
- The following transform uses polar coordinate values in a\
- cartesian reference, resulting in something that looks like\
- what you'd see in a cylindrical mirror\
- new[x,y] = old[a * X/A, r * Y/R] ; page 48\
- The image generated by\
- new[x,y] = old\{ (r/16)*16, (a/16)*16 \} ; page 72\
- is very interesting, in that it is completely unrecognisable\
- when viewed up close, but from a distance of a few metres it\
- will resolve into the original.\
- new[x,y] = old\{r, a + old\{r,a)/8\} ; page 68\
- This image is a swirl, but with the skew dependant on the\
- brightness of the current point.\
- new[x,y] = x < X/2 ? old[x,y] : old[X-x,y]\
- new[x,y] = x > X/2 ? old[x,y] : old[X-x,y]\
- These transformations do a horizontal mirror reversal about\
- the centre of the image. Because faces are usually close\
- to, but not exactly, centered, this transform of a face can\
- be interesting.\
- new[x,y] = old[x+(x%32)-16, y] ; page 58\
- new[x,y] = old[x+((a+r/10)%32)-16, y]\
- These transforms applied to a face produce what looks like\
- someone peering through a bathroom window.\
- DRIVERS\
- nulldev\
- The null device driver is mainly for people with no\
- graphics display device for which a driver exists.\
- Using this device, data for a PostScript or Epson\
- printer can still be generated.\
- atariterm\
- The atari driver is for use with "TERM", a multiplexing\
- terminal program for the Atari ST, written by Peter\
- Collinson of the University of Kent at Canterbury. It\
- is not a driver for running native on an atari.\
- kermit\
- This is a driver for MS-Kermit 2.32 on an IBM PC, which\
- is capable of emulating a Tektronix 4010. This provides\
- three levels of contrast (nothing, normal and bold).\
- MGR This driver is for the Bell Core MGR window system. It\
- is visually identical to the SunView version, but is\
- currently hardwired to monochrome.\
- NeWS This is the driver that will work with NeWS v1.1 and\
- OpenWindows v1.0. It is also visually identical to the\
- SunView version.\
- pcturbo\
- This is a driver for running popi native on a PC with\
- Borland's Turbo C compiler. It uses the graphics\
- library supplied with Turbo C, which auto-detects most\
- types of graphics display. No attempt at using a\
- colourmap is done - a single display dot is used for\
- each image pixel, with simple dithering. Only directly\
- accesible memory is used, which drastically restricts\
- the size of images that can be handled.\
- SunView\
- This driver is the initial version to work with the\
- SunView graphics package available on Sun Workstations.\
- There is currently minimal functionality. The output\
- is in 256 greyscales on colour machines, and an 8x8\
- dither on monochrome screens.\
- X11 A graphics implementation for use with MIT's X11 window\
- system. This driver is visually identical to the Sun-\
- View version.\
- XView\
- A conversion of the SunView graphics driver to use the\
- XView X11 toolkit. This driver is visually identical to\
- the SunView version.\
- SEE ALSO\
- ipscript(1L), imavg(1L).\
- AUTHOR\
- Gerald J. Holzmann, AT&T Bell Laboratories, Murray Hill, New\
- Jersey.\
- Modifications and additional functionality, Atari, PC,\
- PostScript, Epson and null drivers by Stephen Frede, Softway\
- Pty Ltd, Australia.\
- Popi maintainance, SunView, X11, NeWS, MGR and XView graph-\
- ics drivers by Rich Burridge, Sun Microsystems, Australia.\
- Kermit graphics driver by Frank Crawford, Q.H. Tours.\
- Amiga graphics driver by Peter Chubb, Softway Pty Ltd, Aus-\
- tralia.\
- Apollo driver by Tim Lambert, University of New South Wales.\
- BUGS\
- Functions which require popen() (ie auto reading of\
- compressed files and writing to pipes) don't work in the\
- sequent multiprocessor version.\
- Probably more - please notify richb@sunaus.oz.au of any\
- found.\
- CREDITS\
- This implementation is heavily based on version 2.1 of the\
- popi implementation by Rich Burridge & Stephen Frede.\
- CHANGES IN CIC\
- All special functions (#...) were removed. No support for \
- multiple images, only old and new exist.\
- In addition to the standard variables the following CIC\
- variables can be used in popi code:\
- - pencilPressure, pencilDX, pencilDY\
- - currentShot, maxShots\
- - select1 - select5, range1 - range5\
- Also, three free variables that can be adjusted by sliders\
- are allowed:\
- - A, B, C\
- The original variable 'A' in popi, which always had a value\
- of 360, has been removed.
- Module Info
- NXStringTable
- HashTable
- moduleName
- TheWindow
- Field1
- HelpPanel
- Field2
- Button2
- Alpha
- Slider2
- VersionNumber
- ScrollingText
- Field3
- Button1
- Field
- File's Owner
- Slider1
- InfoPanel
- Form1
- Form2
- [29@]
- IBOutletConnector
- IBConnector
- actionView
- stringTable
- IBControlConnector
- takeIntValueFrom:
- PopiCodeScrollView
- PopiErrorTextField
- AValueFormCell
- BValueFormCell
- LimiterButton
- CValueFormCell
- showPreset:
- makeKeyAndOrderFront:
- channelMatrix
-